package com.network.service.common;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@Accessors(chain = true)
public class CustomPage<T> {
    /**
     * 当前页数
     */
    private long pageNum;
    /**
     * 每页显示数量
     */
    private long pageSize;
    /**
     * 总条数
     */
    private long total;
    /**
     * 数据列表
     */
    private List<T> data;
    /**
     * 总页数
     */
    private long pages;

    public CustomPage(Page<T> page) {
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.data = page.getRecords();
        this.pages = page.getPages();
    }

    public CustomPage(Integer pageNum, Integer pageSize, Integer pages, Integer total, List data) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
        this.total = total;
        this.data = data;
        this.pages = pages;
    }
}
